/*
 * Sensor.h
 *
 *  Created on: Jan 18, 2009
 *      Author: Andrzej Olchawa
 *      mailto: andrzejolchawa@gmail.com
 *      http://www.hardtechnology.org
 *      This is a part of the Armazd project, which is covered by
 *      GNU GPL v2 license.
 */

#ifndef SENSOR_H_
#define SENSOR_H_

/* Include section */
#include <string>
#include <iostream>
#include <dlfcn.h>
#include <pthread.h>
#include <stdio.h>
#include <typeinfo>

#include "ExternalSensor.h"
#include "DataSender.h"
#include "AgentUtils.h"
#include "AgentException.h"
#include "AgentConfiguration.h"
#include "DataSenderManager.h"
#include "HTFramework/HTThread.h"

/* namespace declaration */
using namespace std;

/* Sensor class definition */
class Sensor : public HTThread<Sensor>, public DataSenderManager
{

private:

	/* Variables related with sensor's information */
	string sensorName;
	string externalSensorPath;
	ExternalSensor *externalSensor;

	/* Variables related with external module */
	void *hExternalModule;
	externalCreate* createExternalSensor;
	externalDestroy* destroyExternalSensor;

public:

	/* Constructors and destructor */
	Sensor();
	Sensor(string, string, int delay);
	virtual ~Sensor();

	/* Getters and setters */
	string getSensorName();
	string getExternalSensorPath();
	ExternalSensor *getExternalSensor();

	void setSensorName(string);
	void setExternalSensorPath(string);
	void setExternalSensor(ExternalSensor *);

	/* Function related with external sensor */
	void loadExternalSensor(string);
	void loadExternalSensor();

	void run();

	/* Other functions */
	string checkParameters();
	void sendDataFromSensors();

};

#endif /* SENSOR_H_ */
